<?php  if(!defined('PATH_HD')){exit;}
final class fn{
	//写入模版文件
	static public function writeFile($sourceFile=null){
		if(is_null($sourceFile)){
			$sourceFile = array(
					PATH_ROOT . '/' . APP_GROUP . '/' . APP . '/tpl/common/header.html',
					PATH_ROOT . '/' . APP_GROUP . '/' . APP . '/tpl/' . CONTROL . '/' . METHOD . 'Content.html',
					PATH_ROOT . '/' . APP_GROUP . '/' . APP . '/tpl/common/sidebar.html',
					PATH_ROOT . '/' . APP_GROUP . '/' . APP . '/tpl/common/footer.html',
			);
		}		
		$targetFile =  PATH_ROOT . '/'.APP_GROUP.'/'. APP . '/tpl/'.CONTROL.'/'.METHOD.'.html';
		if(!is_array($sourceFile)){
			error("writeFile,参数必须是数组");
			return;
		}
		$writeState = false;
		$writeContent = '';
		foreach ($sourceFile as $v){
			if(!is_file($v)) continue;
			if(filemtime($v) > filemtime($targetFile)){
				$writeState = true;
			}
			$writeContent .= file_get_contents($v);
		}
		if($writeState){
			file_put_contents($targetFile, $writeContent);
		}
	}
	//按数组分配变量
	static public function assign_d($arg){
		if(!is_array($arg)){
			error(__FUNCTION__.",参数非数组");
		}
		$obj = new Control();
		foreach ($arg as $k=>$v){
			$obj->assign($k, $v);
		}
	} 
	
	
	
	
	
	
	
	
	
	
	
	
	
}











 ?>